﻿Public Class ColDef
	' # - Include prompt
	' | - Center
	' : - Right align
	' ! - Bold
	' / - Italic
	' [n] - Color
	' {n} - Width
	' (all) - Margin Also: (left/top/right/bottom) or (leftRight/topBottom)
	' <n> - Header
	Private _align = String.Empty
	Private _color = String.Empty
	Private _bold = String.Empty
	Private _italic = String.Empty
	Private _width = String.Empty
	Private _name = String.Empty
	Private _margin = String.Empty
	Private _header = String.Empty
	Private _prompt = String.Empty
	Private _includePrompt As Boolean = False
	Private Sub Reset()
		_align = String.Empty
		_color = String.Empty
		_bold = String.Empty
		_italic = String.Empty
		_width = String.Empty
		_name = String.Empty
		_margin = String.Empty
		_header = String.Empty
		_prompt = String.Empty
		_includePrompt = False
	End Sub
	Public WriteOnly Property Def() As String
		Set(ByVal value As String)
			Call Reset()
			While InStr("|:/![{(#<", Mid(value, 1, 1)) > 0 AndAlso value <> String.Empty
				Select Case Mid(value, 1, 1)
					Case "#" : _includePrompt = True
					Case "|" : _align = "HorizontalAlignment=""Center"" "
					Case ":" : _align = "HorizontalAlignment=""Right"" "
					Case "!" : _bold = "FontWeight=""Bold"" "
					Case "/" : _italic = "FontStyle=""Italic"" "
					Case "["
						value = Mid(value, 2)
						Dim p = InStr(value, "]")
						If p > 0 Then
							_color = String.Format("Foreground=""{0}"" ", Mid(value, 1, p - 1))
							value = Mid(value, p)
						End If
					Case "{"
						value = Mid(value, 2)
						Dim p = InStr(value, "}")
						If p > 0 Then
							_width = String.Format("Width=""{0}*"" ", Mid(value, 1, p - 1))
							value = Mid(value, p)
						End If
					Case "("
						value = Mid(value, 2)
						Dim p = InStr(value, ")")
						If p > 0 Then
							_margin = String.Format("Margin=""{0}"" ", Replace(Mid(value, 1, p - 1), "/", ","))
							value = Mid(value, p)
						End If
					Case "<"
						value = Mid(value, 2)
						Dim p = InStr(value, ">")
						If p > 0 Then
							_header = String.Format("Header=""{0}"" ", Mid(value, 1, p - 1))
							_prompt = Mid(value, 1, p - 1)
							value = Mid(value, p)
						End If
				End Select
				value = Mid(value, 2)
			End While
			_name = value
			If _margin = String.Empty Then
				_margin = String.Format("Margin=""{0}"" ", "2,0,2,0")
			End If
			If _header = String.Empty Then
				_header = String.Format("Header=""{0}"" ", Misc.Names.Title(_name))
				_prompt = Misc.Names.Title(_name)
			End If
		End Set
	End Property
	Public Property Align() As String
		Get
			Return _align
		End Get
		Set(ByVal value As String)
			_align = value
		End Set
	End Property
	Public Property Color() As String
		Get
			Return _color
		End Get
		Set(ByVal value As String)
			_color = value
		End Set
	End Property
	Public Property Bold() As String
		Get
			Return _bold
		End Get
		Set(ByVal value As String)
			_bold = value
		End Set
	End Property
	Public Property Italic() As String
		Get
			Return _italic
		End Get
		Set(ByVal value As String)
			_italic = value
		End Set
	End Property
	Public Property Name() As String
		Get
			Return _name
		End Get
		Set(ByVal value As String)
			_name = value
		End Set
	End Property
	Public Property Width() As String
		Get
			Return _width
		End Get
		Set(ByVal value As String)
			_width = value
		End Set
	End Property
	Public Property Margin() As String
		Get
			Return _margin
		End Get
		Set(ByVal value As String)
			_margin = value
		End Set
	End Property
	Public Property Header() As String
		Get
			Return _header
		End Get
		Set(ByVal value As String)
			_header = value
		End Set
	End Property
	Public Property Prompt() As String
		Get
			Return _prompt
		End Get
		Set(ByVal value As String)
			_prompt = value
		End Set
	End Property
	Public Property IncludePrompt() As Boolean
		Get
			Return _includePrompt
		End Get
		Set(ByVal value As Boolean)
			_includePrompt = value
		End Set
	End Property
End Class